package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-22
 * Time: 22:24
 */

public class Test {
    public static void main(String[] args)
            throws CloneNotSupportedException {
        //浅拷贝
     /*Person person1 = new Person("lili", 2);
     Person person2 = (Person) person1.clone();
        System.out.println(person2);

        System.out.println("修改前" + person1.money.m);
        System.out.println("修改前" + person2.money.m);

        person2.money.m = 20.9;
        System.out.println("修改后" + person1.money.m);
        System.out.println("修改后" + person2.money.m);*/



        //深拷贝
        Person person1 = new Person("lili", 2);
        Person person2 = (Person) person1.clone();
        System.out.println(person2);

        System.out.println("修改前" + person1.money.m);
        System.out.println("修改前" + person2.money.m);

        person2.money.m = 20.9;
        System.out.println("修改后" + person1.money.m);
        System.out.println("修改后" + person2.money.m);
    }
}
